package com.qf.erp_system.sys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.erp_system.common.page.NumberParam;
import com.qf.erp_system.common.pojo.sys.SysNumber;
import com.qf.erp_system.sys.dao.SysNumberDAO;
import com.qf.erp_system.sys.service.SysNumberService;
import com.qf.erp_system.sys.vo.PageVo;
import com.qf.erp_system.sys.vo.SysNumberVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import java.util.List;

@Service
public class SysNumberServiceImpl implements SysNumberService {
    @Resource
    private SysNumberDAO sysNumberDAO;

    @Override
    public PageVo<SysNumberVo> listSysNumberVo(NumberParam numberParam) {
        PageHelper.startPage(numberParam.getPage(),numberParam.getLimit());
        List<SysNumberVo> sysNumberVos = sysNumberDAO.listSysNum(numberParam);
        PageInfo<SysNumberVo> pageInfo = new PageInfo<>(sysNumberVos);
        PageVo<SysNumberVo> pageVo = new PageVo<>();
        pageVo.setCurrentPage(pageInfo.getPageNum());
        pageVo.setCount(pageInfo.getSize());
        pageVo.setDataList(sysNumberVos);
        return pageVo;
    }

    @Override
    public void add(SysNumber record) {
        sysNumberDAO.insert(record);
    }


}
